<?php $this->_extends('../_layouts/default_layout'); ?>
<?php $this->_block('contents'); ?>
<link type="text/css" href="<?=Q::ini('custom_system/base_url')?>css/prettyphoto.css" rel="stylesheet" />
<script type="text/javascript" src="<?=Q::ini('custom_system/base_url')?>js/jq.prettyphoto.js"></script>
<script type="text/javascript">
$(function(){
	$("a[rel^='pretty_photo']").prettyPhoto({theme:'facebook'});
	$(".datepicker").datepicker({dateFormat:'yy-mm-dd',changeMonth:true});
	$(".parent").children().hide();
	$(".parent").addClass("pointer").toggle(
		function(){$(this).children().show();
		},function(){$(this).children().hide();}
	);
});
</script>
<style>
.pointer {cursor: pointer;}
</style>
<fieldset><legend>查询条件</legend>
<form method="get">
<? include(Q::ini('custom_system/elements_dir') . 'searchform_element.php');?>
<table class="form_table">
<tr>
	<th>发货日期</th>
	<td>
		<input type="text" name="begin_shipped_time" class="datepicker" value="<?=isset($_GET['begin_shipped_time']) ? $_GET['begin_shipped_time'] : ''?>" /> to
		<input type="text" name="end_shipped_time" class="datepicker" value="<?=isset($_GET['end_shipped_time']) ? $_GET['end_shipped_time'] : ''?>" />
	</td>
</tr>
<tr>
	<th>网站</th>
	<td><select name="shop_id">
		<option value="">请选择..</option>
		<?foreach ($shop as $s):?>
		<option value="<?=$s['id']?>" <?if (isset($_GET['shop_id']) && $_GET['shop_id'] == $s['id']) echo "selected='selected'";?>><?=$s['name']?></option>
		<?endforeach;?>
	</select></td>
</tr>
<tr>
	<td><input type="hidden" name="is_search" value="1" /></td>
	<td><input type="submit" class="button" value="查询" /></td>
	<?if (isset($_GET['is_search'])):?><td><a href="<?=url('DataCenter::Warehouse/ExportResendRate', array('begin_shipped_time' => $_GET['begin_shipped_time'], 'end_shipped_time' => $_GET['end_shipped_time'], 'shop_id' => $_GET['shop_id']))?>">导出错漏发货产品</a></td><?endif;?>
</tr>
</table>
</form>
</fieldset>
<?if (isset($_GET['is_search']) && $_GET['is_search']):?>
<p><big>发货总单数：<?=$all_count?></big></p>
<p><big>重发单数：<?=$resend_count?> &nbsp; &nbsp;(<?=($resend_count ? sprintf('%.2f', $resend_count/$all_count*100) : '0.00') . '%'?>)</big></p>

<ul style="list-style: disc; padding: 10px;">
	<?foreach ($reason as $key => $r):?>
	<li style="margin: 5px;"><?=$r['name']?>：<?=$r['count']?> &nbsp; &nbsp;(<?=($resend_count ? sprintf('%.2f', $r['count']/$resend_count*100) : '0.00') . '%'?>)
		<ul style="list-style: circle;">
			<li style="margin-left: 15px;" class="parent">产品： <?=$r['product']['count']?>
				<ul>
					<?foreach ($r['product']['detail'] as $d):?>
					<li><?=$d['number']?> * <?=$d['count']?> <?=$d['name']?>
						<?$pretty_photo_number = 0;?>
						<?foreach ($d['pic_url'] as $dp):?>
						<a rel="pretty_photo[<?=$key?>_<?=$d['number']?>]" href="<?=$dp?>"><?if(!$pretty_photo_number):?><span class="img_icon" style="float: left;"></span><?endif;?></a>
						<?$pretty_photo_number = 1;?>
						<?endforeach;?>
					</li>
					<?endforeach;?>
				</ul>
			</li>
			<li style="margin-left: 15px;" class="parent">邮寄方式
				<ul>
					<?foreach ($r['shipping_method'] as $k => $sm):?>
					<li><?=$k?> <?=$sm?></li>
					<?endforeach;?>
				</ul>
			</li>
			<li style="margin-left: 15px;" class="parent">国家
				<ul>
					<?foreach ($r['country'] as $k => $rc):?>
					<li><?=$k?> <?=$rc?></li>
					<?endforeach;?>
				</ul>
			</li>
		</ul>
	</li>
	<?endforeach;?>
</ul>
<?endif;?>
<?php $this->_endblock();?>